PEEK Function ---------------------------------------------------------------------------- Action Returns byte value stored at a specified memory location. Complements the POKE statement. Syntax PEEK( address) Remarks The returned value is an integer between 0 and 255, inclusive. The argument address is a value between 0 and 65,535, inclusive. The argument address is treated as the offset from the current default segment (as set by the DEF SEG statement). If address is a single- or double-precision floating-point value, or a long integer, it is converted to a 2-byte integer. When using PEEK to return a byte from a far-string array, use the SSEG and SADD functions to obtain the current segment and offset. For example. DEF SEG = SSEG(a$) ' Set current segment address to address of a$. StringOffset = SADD(a$) ' Determine string's location within segment. PEEK(StringOffset)' Return the byte stored at this location. Direct string manipulation with PEEK should be used cautiously, because BASIC moves string locations during run time. PEEK and Expanded Memory Arrays Do not use PEEK to return a byte from an expanded memory array. If you start QBX with the -Ea switch, any of these arrays may be stored in expanded memory. - Numeric arrays less than 16K in size. - Fixed-length string arrays less than16K in size. - User-defined-type arrays less than 16K in size. If you want to use PEEK to return a byte from an array, first start QBX without the -Ea switch. (Without the -Ea switch, no arrays are stored in expanded memory.) For more information on using expanded memory, see "Memory Management for QBX" in Getting Started. Note When programming with OS-2 protected mode, note that any address referred to by PEEK must be readable. If PEEK refers to an address for which your process does not have read permission, the operating system may generate a protection exception, or BASIC may generate the error message Permission denied. See Also DEF SEG; POKE; SADD; SSEG; SSEGADD; VARPTR, VARSEG; VARPTR$ Example See the DEF SEG statement programming example, which uses the PEEK statement.